import kohutils
class Player():
    def __init__(self):
        self.faceDownCards = []
        self.faceUpCards = []
        self.hand = []

    def playCard(self, pileCards, indexHand, indexCard):
        # Plays a card.
        # indexHand: 0 = hand, 1 = cards on field 
        # indexCard = which card
        if indexHand == 0:
            if not self.hand:
                return False
            else:
                if len(self.hand) >= indexCard:
                    card = self.hand[indexCard]
                    if card < pileCards[len(pileCards) - 1]:
                        return False
                    self.hand.pop(indexCard)
                    pileCards.append(card)
                    return pileCards
                else:
                    return False
        elif indexHand == 1:
            if self.hand:
                return False
            else:
                if self.faceUpCards[indexCard] == None:
                    if self.faceDownCards == None:
                        return False
                    else:
                        card = self.faceDownCards[indexCard]
                        if card < pileCards[len(pileCards) - 1]:
                            return False
                        self.faceDownCards[indexCard] = None
                        pileCards.append(card)
                        return pileCards
                else:
                    card = self.faceUpCards[indexCard]
                    if card < pileCards[len(pileCards) - 1]:
                        return False
                    self.faceUpCards[indexCard] = None
                    pileCards.append(card)
                    return pileCards
    def switchFaceUpCard(self, indexCard, card):
        
        if not kohutils.restrictInput(indexCard, 0, 2):
            return False
        
        tmpCard = self.faceUpCards[indexCard]
        self.faceUpCards = card
        return tmpCard
